<?php

require_once '../include/common.inc.php';

if (!checkAdmin()) {
    header("LOCATION:index.php");
    exit;
}


$filename = 'customer.xls';

header("Content-type:application/vnd.ms-excel");
header("Accept-Ranges:bytes");
header("Content-Disposition:attachment;filename=".$filename);


$sql = "SELECT * FROM `user` ORDER BY `id` ASC";
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {
    $out_ary[] = $rs;
}

$s = "Name\tContact\tCity\tCountry\tEmail\tUsername\tPassword\tStatus\n";

foreach($out_ary as $v) {
    $s .= $v['company'] . "\t" . $v['firstname'] . "\t" . $v['city'] . "\t" . $COUNTRY_ARY[$v['countryid']] . "\t" . $v['email']. "\t" . $v['username'] .  "\t" . $v['password2'] .  "\t" . $USER_STATUS_ARY[$v['status']] . "\n";
}

echo $s;

?>